// public utils for nodejs
var config = require("../config");

module.exports = {
  agent: function (req, res) {
    var deviceAgent = req.headers["user-agent"].toLowerCase();
    var mobileDevice = deviceAgent.match(/(iphone|ipod|ipad|android)/);
    return mobileDevice;
  },
  login: function (req, res, next) {
    var user = req.session.user;
    if (user) {
      next();
    } else {
      res.redirect('/login');
    }
  }
}